package com.asteros.common.util;

import java.io.IOException;
import java.io.StringReader;
/*import ru.CryptoPro.JCP.tools.Decoder;
import ru.CryptoPro.JCP.tools.Encoder;*/

public final class Base64Util
{
  private static final int COLUMN_LEN = 64;
  private static final String NR = "\n\r";

  public static String toBase64String(String src)
    throws IOException
  {
    return toBase64String(src, "", "");
  }

  public static String toBase64String(String src, String appendStart, String appendEnd) throws IOException
  {
    StringBuffer resBuf = new StringBuffer(appendStart);
    StringReader strRead = new StringReader(src.trim());

    int counter = 0;
    int c;
    while ((c = strRead.read()) != -1)
    {
      if ((c != 10) && (c != 13) && (c != 32)) {
        resBuf.append((char)c);
        counter++; 
        if (counter % 64 != 0) continue; 
        resBuf.append("\n\r");
      }
    }
    resBuf.append("\n\r").append(appendEnd);

    return resBuf.toString();
  }

/*  public static String encode(byte[] buf) throws Exception
  {
    Encoder encoder = new Encoder();
    return encoder.encodeBuffer(buf);
  }

  public static byte[] decode(String str) throws Exception
  {
    Decoder decoder = new Decoder();
    return decoder.decodeBuffer(str);
  }*/
}

/* Location:           C:\Users\Kirill\Desktop\esign\esign\esign.jar
 * Qualified Name:     com.topsbi.common.util.Base64Util
 * JD-Core Version:    0.6.0
 */